#!/bin/bash

# Stop on error
set -e

# Disable extension if already enabled; don't stop if already disabled
gnome-shell-extension-tool -d alternate-tab@gnome-shell-extensions.gcampax.github.com || true
gnome-shell-extension-tool -d window-list@gnome-shell-extensions.gcampax.github.com || true
gnome-shell-extension-tool -d places-menu@gnome-shell-extensions.gcampax.github.com || true
gnome-shell-extension-tool -d system-monitor@paradoxxx.zero.gmail.com || true

# Install extensions
gnome-shell-extension-tool -e alternate-tab@gnome-shell-extensions.gcampax.github.com
gnome-shell-extension-tool -e window-list@gnome-shell-extensions.gcampax.github.com
gnome-shell-extension-tool -e places-menu@gnome-shell-extensions.gcampax.github.com

# Install system-monitor dependencies
sudo apt-get install gir1.2-gtop-2.0 gir1.2-networkmanager-1.0
# Delete extension folder if exists
rm -rf ~/.local/share/gnome-shell/extensions/system-monitor@paradoxxx.zero.gmail.com || true
# Assert local extensions folder
mkdir -p ~/.local/share/gnome-shell/extensions
# Download latest version
wget -O- https://github.com/marxin/gnome-shell-system-monitor-applet/archive/fix-issue-290.tar.gz | tar --strip-components=1 -C ~/.local/share/gnome-shell/extensions -xzv gnome-shell-system-monitor-applet-fix-issue-290/system-monitor@paradoxxx.zero.gmail.com
# Enable extension
gnome-shell-extension-tool --enable-extension=system-monitor@paradoxxx.zero.gmail.com
